import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class FeedbackPage extends StatelessWidget {
  final TextEditingController _nameController = TextEditingController();
  final TextEditingController _emailController = TextEditingController();
  final TextEditingController _feedbackController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('反馈'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              '您的姓名',
              style: TextStyle(fontSize: 16),
            ),
            TextField(
              controller: _nameController,
              decoration: InputDecoration(
                hintText: '请输入您的姓名',
              ),
            ),
            SizedBox(height: 16),
            Text(
              '您的邮箱',
              style: TextStyle(fontSize: 16),
            ),
            TextField(
              controller: _emailController,
              decoration: InputDecoration(
                hintText: '请输入您的邮箱',
              ),
            ),
            SizedBox(height: 16),
            Text(
              '您的反馈',
              style: TextStyle(fontSize: 16),
            ),
            SizedBox(height: 16),
            Container(
              padding: const EdgeInsets.all(8.0),
              decoration: BoxDecoration(
                border: Border.all(color: Colors.grey),
                borderRadius: BorderRadius.circular(8.0),
              ),
              child: TextField(
                controller: _feedbackController,
                decoration: InputDecoration(
                  hintText: '请输入您的反馈',
                  border: InputBorder.none,
                ),
                maxLines: 5,
              ),
            ),
            SizedBox(height: 16),
            Center(
              child: ElevatedButton(
                onPressed: () {
                  // Handle the feedback submission logic
                  _showThankYouDialog(context);
                },
                child: Text('提交'),
              ),
            ),
          ],
        ),
      ),
    );
  }

  void _clearFields() {
    _nameController.clear();
    _emailController.clear();
    _feedbackController.clear();
  }

  void _showThankYouDialog(BuildContext context) {
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('谢谢您的反馈'),
          content: Text('我们已经收到您的反馈，谢谢！'),
          actions: [
            TextButton(
              onPressed: () {
                Navigator.of(context).pop();
                _clearFields();
              },
              child: Text('关闭'),
            ),
          ],
        );
      },
    );
  }
}
